package com.xci.edu.module.foreground.pc.train.core;

import com.xci.edu.core.entity.EduStudent;
import com.xci.edu.core.service.TrainStudentService;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ModelAttribute;

import javax.annotation.Resource;

/**
 * 全局注入变量到Web页面中
 */
@ControllerAdvice
public class TrainWebControllerAdvice {
    //上面定义的组件类
    @Resource
    private TrainStudentService trainStudentService;

    //注解参数就是页面引用的名称
    @ModelAttribute("currentStudent")
    public EduStudent initSysWebPage() {
        return trainStudentService.getCurrentStudent();
    }
}
